package com.starview.star.compiler.ast;

import com.starview.platform.data.EvaluationException;
import com.starview.platform.data.IFunction;
import com.starview.platform.data.IValue;
import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.Location;
import com.starview.platform.data.type.TypeUtils;
import com.starview.platform.data.value.StringWrap.StringWrapper;
import com.starview.star.operators.CafeEnter;

public class MacroError implements IFunction
{
  public static final String name = "__error_msg";

  @CafeEnter
  public static IValue enter(Location loc, IValue msg) throws EvaluationException
  {
    throw new EvaluationException(StringWrapper.nonStringEnum, msg, loc);
  }

  @Override
  public IValue enter(IValue... args) throws EvaluationException
  {
    return enter((Location) args[0], args[1]);
  }

  @Override
  public IType getType()
  {
    return type();
  }

  public static IType type()
  {
    return TypeUtils.functionType(Location.type, ASyntax.type, ASyntax.type);
  }
}
